package com.wicket.okrframework.web.contorller;

import com.github.pagehelper.Page;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrframework.biz.service.StaffingService;
import com.wicket.okrframework.biz.service.dto.req.*;
import com.wicket.okrframework.biz.service.dto.res.*;
import com.wicket.okrframework.common.ro.OkrResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/base/staffing/")
public class StaffingController {
    @Autowired
    StaffingService staffingService;

    /**
   * D1-3新增编制
   */
    @PostMapping("addStaffing")
    public OkrResult<AddStaffingRespDto> addStaffing(@RequestBody @Validated AddStaffingReqDto reqDTO){
    return OkrResult.success(staffingService.addStaffing(reqDTO));
    }

    /**
   * D1-3批量补充编制
   */
    @PostMapping("batchUpdateStaffing")
    public OkrResult<BatchUpdateStaffingRespDto> batchUpdateStaffing(@RequestBody @Validated BatchUpdateStaffingReqDto reqDTO){
    return OkrResult.success(staffingService.batchUpdateStaffing(reqDTO));
    }

    /**
   * D1-3补充编制
   */
    @PostMapping("updateStaffing")
    public OkrResult<UpdateStaffingRespDto> updateStaffing(@RequestBody @Validated UpdateStaffingReqDto reqDTO){
    return OkrResult.success(staffingService.updateStaffing(reqDTO));
    }

    /**
   * D1-3查询编制账户详情
   */
    @PostMapping("queryStaffingAccountDetail")
    public OkrResult<QueryStaffingAccountDetailRespDto> queryStaffingAccountDetail(@RequestBody @Validated QueryStaffingAccountDetailReqDto reqDTO){
    return OkrResult.success(staffingService.queryStaffingAccountDetail(reqDTO));
    }

    /**
   * D1-3批量新增编制
   */
    @PostMapping("batchAddStaffing")
    public OkrResult<BatchAddStaffingRespDto> batchAddStaffing(@RequestBody @Validated BatchAddStaffingReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        BatchAddStaffingRespDto retData = staffingService.batchAddStaffing(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3存档编制
   */
    @PostMapping("archiveStaffing")
    public OkrResult<ArchiveStaffingRespDto> archiveStaffing(@RequestBody @Validated ArchiveStaffingReqDto reqDTO){
    return OkrResult.success(staffingService.archiveStaffing(reqDTO));
    }

    /**
   * D1-3发布编制
   */
    @PostMapping("releaseStaffing")
    public OkrResult<ReleaseStaffingRespDto> releaseStaffing(@RequestBody @Validated ReleaseStaffingReqDto reqDTO){
    return OkrResult.success(staffingService.releaseStaffing(reqDTO));
    }

    /**
   * D1-3查询编制列表
   */
    @PostMapping("queryStaffingList")
    public OkrResult<QueryStaffingListRespDto> queryStaffingList(@RequestBody @Validated QueryStaffingListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryStaffingListRespDto retData = staffingService.queryStaffingList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }
/**
   * D1-3执行批次发布编制处理(公共)
   */
    @PostMapping("implementBatchStaffingHandleCom")
    public OkrResult<ImplementBatchStaffingHandleComRespDto> implementBatchStaffingHandleCom(@RequestBody @Validated ImplementBatchStaffingHandleComReqDto reqDTO){
    return OkrResult.success(staffingService.implementBatchStaffingHandleCom(reqDTO));
    }
/**
   * D1-执行批次存档编制处理(公共)
   */
    @PostMapping("implementBatchStaffingArchiveCom")
    public OkrResult<ImplementBatchStaffingArchiveComRespDto> implementBatchStaffingArchiveCom(@RequestBody @Validated ImplementBatchStaffingArchiveComReqDto reqDTO){
    return OkrResult.success(staffingService.implementBatchStaffingArchiveCom(reqDTO));
    }
/**
   * D1-执行批次新增编制处理(公共)
   */
    @PostMapping("implementBatchStaffingCreateCom")
    public OkrResult<ImplementBatchStaffingCreateComRespDto> implementBatchStaffingCreateCom(@RequestBody @Validated ImplementBatchStaffingCreateComReqDto reqDTO){
    return OkrResult.success(staffingService.implementBatchStaffingCreateCom(reqDTO));
    }
}
  